import pyperclip as clip
import json
import pandas as pd
from sqlalchemy import create_engine

if __name__ == '__main__':
    # 连接database
    engine = create_engine('mysql+pymysql://jsbi:jsbi-1701@47.114.55.19:9011/biv1?charset=utf8')
    con = engine.connect()
    value = clip.paste()
    jsonFromWeb = json.loads(value)
    df = pd.read_json(json.dumps(jsonFromWeb['result']['goodsDetailList']))
    # 解决可能出现的超时问题bugfix 2020.08.18
    con.connection.connection.ping(reconnect=True)
    df.to_sql(name='t_pdd_sjht_spmx', con=con, if_exists='append', index=False)
